
<%
Private Function GetMenuByUserID(UserId, resPPath ,res_page_code)
''查找某个用户对应的权限对应的资源的信息，生成菜单
''Response.Write "--<<<" & UserId & "-----" & resPPath & ">>>---"
	Dim rsObjT,strSql
	Set rsObjT = Server.CreateObject("ADODB.Recordset")
	strSql=""
	strSql=strSql & " SELECT  DISTINCT mm.* from("
	strSql=strSql & " SELECT TOP 100  T_RES.menu_name,T_RES.menu_code,T_RES.res_url,T_RES.res_ppath , T_RES.menu_num"
	strSql=strSql & " , sel=CASE  WHEN T_RES.res_num ='"&res_page_code&"' THEN 'on' ELSE ''  END "
	strSql=strSql & " FROM T_RES INNER JOIN T_ROLE_RES INNER JOIN T_USER_ROLE  "
	strSql=strSql & " ON T_ROLE_RES.role_id = T_USER_ROLE.role_id ON  T_RES.id = T_ROLE_RES.res_id "
	strSql=strSql & "  WHERE (T_USER_ROLE.user_id = '"&UserId&"') AND (T_RES.menu_show = 1) "
	strSql=strSql & "  AND (LEFT(T_RES.res_ppath+'',len('"& resPPath &"')) = '"& resPPath &"') "
	strSql=strSql & " ORDER BY T_RES.res_ppath + cast(T_RES.id AS varchar(5)) , T_RES.menu_num "
	''strSql=strSql & " ) mm ORDER BY  mm.menu_code ,mm.res_ppath , mm.menu_num "
	strSql=strSql & " ) mm ORDER BY   mm.menu_num "

	''Response.Write strSql&"-----<br>"
	rsObjT.Open strSql, Conn, 1, 3
	If rsObjT.BOF And rsObjT.EOF Then 
			'nothing
		'end if	 
		'UserID=ReplaceBadChar(Trim(rsObjT("UserID")))
 	else
		Dim menuHtml,menuHtmlStart,menuHtmlEnd ,menuHtmlStart1 , menuHtmlEnd1
		menuHtml=""
		menuHtmlStart=""
		menuHtmlEnd=""
		menuHtmlStart1=""
		menuHtmlEnd1=""
	  	Do While Not rsObjT.EOF
		    if ("0_"=rsObjT("res_ppath"))then 
			    menuHtml= menuHtml & menuHtmlStart  &menuHtmlStart1   & menuHtmlEnd1 & menuHtmlEnd
			    menuHtmlStart =""
			    menuHtmlEnd =""
			    menuHtmlStart1 =""
			    menuHtmlEnd1 =""			    
		    	menuHtmlStart= "<li><a href='" & rsObjT("res_url")&"' id='" & rsObjT("menu_code") & "' name='" & rsObjT("menu_code") & "'><strong><span>" & rsObjT("menu_name") & "</span></strong></a>"
		    	menuHtmlEnd= "</li>"
		    	menuHtmlStart1= "<div class='menu' style='display:none'><ol>" 
				menuHtmlEnd1 = "</ol></div>"
		    else 
		    	menuHtmlStart1=menuHtmlStart1 & "<li><a href='" & rsObjT("res_url")&"'>" & rsObjT("menu_name")&"</a></li>"
		    end if 
	 		rsObjT.MoveNext 
	  	Loop
	  	menuHtml= menuHtml & menuHtmlStart  &menuHtmlStart1   & menuHtmlEnd1 & menuHtmlEnd
	   	 ''Response.Write "-----<br><br>" & strHtml &"<br><br>-----"
	end if 
			rsObjT.close
			Set rsObjT = Nothing 

 '释放数据库链接
	''call CloseConn	 


GetMenuByUserID = menuHtml
End Function
%>


<!--begin navigation-->
<div class="navigation nav-orange" id="navigation" name="navigation">
	<div class="nav-tabs">
		<ul>
			
	 <% 
	 	'菜单示例
	 	'	<li><a href="/console/point/point.php" name="point"><strong><span>积分管理</span></strong></a>
		'		<div class="menu" style="display:none">
		'			<ol>
		'				<li><a href="/console/point/point.php">消费积分</a></li>
		'				<li><a href="/console/point/coin.php">花生米</a></li>
		'			</ol>
		'		</div>
		'	</li>	 	
	 	''Response.Write "--------respagecode----"&respagecode &"-----------<BR>"	
	 	Response.Write ""&GetMenuByUserID(Session("UserID"),"0_",respagecode)	
	%>	
 
		</ul>
	</div>
</div>
<!--script type="text/javascript">//$("#navigation").menu('point');</script-->
<!--end navigation-->




 